# 简单的文件上传测试脚本

$filePath = "test2.txt"
$url = "http://localhost:8081/api/file/upload"

# 创建WebClient
$webClient = New-Object System.Net.WebClient

try {
    # 上传文件
    $response = $webClient.UploadFile($url, $filePath)
    
    # 将响应转换为字符串
    $responseString = [System.Text.Encoding]::UTF8.GetString($response)
    
    Write-Host "Upload successful!"
    Write-Host "Response: $responseString"
} catch {
    Write-Host "Error: $($_.Exception.Message)"
    if ($_.Exception.Response) {
        $statusCode = [int]$_.Exception.Response.StatusCode
        Write-Host "Status Code: $statusCode"
    }
} finally {
    # 清理资源
    $webClient.Dispose()
}